﻿<Page
    x:Class="SharPy.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:SharPy"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    mc:Ignorable="d">

    <Page.Resources>
        <!-- Совместимый с сеткой шаблон элемента 310 на 260 пикселей, как показано в разделе 4 -->
        <DataTemplate x:Key="Standard310x260ItemTemplate">
            <Grid Height="250" Width="310" Margin="5,10,5,10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" Height="150">
                    <Image Source="{Binding ImagePath}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/>
                </Border>
                <StackPanel Grid.Row="1" Margin="0,10,0,0">
                    <TextBlock Text="{Binding Title}" Style="{StaticResource TitleTextBlockStyle}" TextWrapping="NoWrap"/>
                    <TextBlock Text="{Binding Description}" Style="{StaticResource BodyTextBlockStyle}" MaxHeight="60" />
                </StackPanel>
            </Grid>
        </DataTemplate>
    </Page.Resources>

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Hub Header="{Binding Title}" SectionHeaderClick="SectionHeaderClick">
            <HubSection Width="800" Header="Current game" IsHeaderInteractive="True" >
                <DataTemplate>
                    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <Image Name="imHeroImage" Stretch="UniformToFill" Width="800" Height="800" Source="{Binding HeroImageSource}"></Image>
                        <StackPanel Orientation="Vertical">
                            <Button Content="Continue last game" Click="ContinueLastGame" Margin="0,0,-3,0" Width="723"/>
                            <Button Content="Restart last game" HorizontalAlignment="Stretch" Click="RestartLastGame" VerticalAlignment="Center" Margin="0,0,-3,0"/>
                            <Button x:Name="Refresh" Content="Refresh games list" Click="Refresh_Click" VerticalAlignment="Top" HorizontalAlignment="Left" Width="723" Margin="0,0,-3,0"/>
                            <Button Content="Choose local game" HorizontalAlignment="Center" VerticalAlignment="Center" Click="LocalGame_Click" Margin="-3,0" Width="726"></Button>
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </HubSection>
            <HubSection IsHeaderInteractive="True" DataContext="{Binding gameItems}"
                        x:Uid="Section3Header" Header="Games available!" Padding="40,40,40,32">
                <DataTemplate>
                    <GridView
                        x:Name="itemGridView"
                        ItemsSource="{Binding Items}"
                        Margin="-9,-14,0,0"
                        AutomationProperties.AutomationId="ItemGridView"
                        AutomationProperties.Name="Items In Group"
                        ItemTemplate="{StaticResource Standard310x260ItemTemplate}"
                        SelectionMode="None"
                        IsSwipeEnabled="false"
                        IsItemClickEnabled="True"
                        ItemClick="ItemView_ItemClick">
                        <FlyoutBase.AttachedFlyout>
                            <Flyout Placement="Right">
                                <StackPanel Orientation="Vertical" >
                                    <TextBlock Text="{Binding SelectedGame}"></TextBlock>
                                    <Button Name="Download" Content="Download/Play" Click="Download_Click" Width="160"></Button>
                                    <Button Name="Restart" Content="Restart" Click="Restart_Click" Width="160"></Button>
                                    <Button Name="Delete" Content="Delete" Click="Delete_Click" Width="160"></Button>
                                </StackPanel>
                            </Flyout>
                        </FlyoutBase.AttachedFlyout>
                    </GridView>
                </DataTemplate>
            </HubSection>
            <HubSection Header="Log" Width="400" IsHeaderInteractive="True">
                <DataTemplate>
                    <Grid>
                        <StackPanel>
                            <TextBlock  TextWrapping="Wrap" Text="{Binding Log}" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="White" Width="390"/>
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </HubSection>
            <HubSection Name="About" Header="About" Width="500" IsHeaderInteractive="True" >
                <DataTemplate>
                    <Grid>
                        <StackPanel>
                            <TextBlock Text="{Binding AboutText}"></TextBlock>
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </HubSection>
			<HubSection Header="News" Width="300">
				<DataTemplate>
					<WebView></WebView>
				</DataTemplate>
			</HubSection>
        </Hub>
    </Grid>
</Page>